package com.igeekhome.wzgl.controller;

import com.igeekhome.wzgl.entity.AdministratorEntity;
import com.igeekhome.wzgl.service.IAdministrator;
import org.apache.ibatis.annotations.Update;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/ad")
@CrossOrigin
public class AdministratorController {
    @Autowired
    private IAdministrator iAdministrator;
    @PostMapping("/regist")
    public int regist(@RequestBody AdministratorEntity re){
        return iAdministrator.regist(re);
    }
    @GetMapping("/isCanUse")
    public int isCanUse(@RequestParam String account){
        return iAdministrator.isCanUse(account);
    }
    @PostMapping("/login")
    public AdministratorEntity login(@RequestBody AdministratorEntity ad){
        return iAdministrator.login(ad);
    }
    @PostMapping("/addAdministrator")
    public int addAdministrator(@RequestBody AdministratorEntity admin){
        return iAdministrator.addAdministrator(admin);
    }
    @GetMapping("/delete")
    public int delete(@RequestParam int id){
        return iAdministrator.delete(id);
    }

    @PostMapping("/updata")
    public int updata(@RequestBody AdministratorEntity ad) {
        return  iAdministrator.updata(ad);
    }
    @GetMapping("/search")
    public List<AdministratorEntity> search(@RequestParam int id){
        return iAdministrator.search(id);
    }

    @GetMapping("/page")
    public  List<AdministratorEntity> page(){
        return iAdministrator.page();
    }

    @GetMapping("/getById")
    public AdministratorEntity getById(@RequestParam int id){
        return iAdministrator.getById(id);
    }
}
